/**
 * 
 */
package com.dalonedrau.jogl.opengl.sprite;

import java.awt.Dimension;

/**
 * @author Donald
 */
public final class SpriteImageObject {
	/** the image's bottom corner. */
	private float	bottom;
	/** the image's height. */
	private int		height;
	/** the image's left corner. */
	private float	left;
	/** the image's parent texture's height. */
	private float	parentHeight;
	/** the image's parent texture's width. */
	private float	parentWidth;
	/** the image's reference id. */
	private int		refId;
	/** the image's right corner. */
	private float	right;
	/** the name of the parent texture. */
	private int		textureId;
	/** the image's top corner. */
	private float	top;
	/** the image's height. */
	private int		width;
	/**
	 * Creates a new instance of {@link SpriteImageObject}.
	 * @param imgLeft the image's left corner
	 * @param imgTop the image's top corner
	 * @param imgWidth the image's width
	 * @param imgHeight the image's height
	 * @param parentSize the image's parent texture's size
	 * @param tId the reference id of the parent texture
	 * @param rId the image's reference id
	 */
	public SpriteImageObject(final int imgLeft, final int imgTop,
			final int imgWidth, final int imgHeight,
			final Dimension parentSize,
			final int tId, final int rId) {
		parentHeight = parentSize.height;
		parentWidth = parentSize.width;
		width = imgWidth;
		height = imgHeight;
		top = imgTop / parentHeight;
		left = imgLeft / parentWidth;
		bottom = top + height / parentHeight;
		right = left + width / parentWidth;
		textureId = tId;
		refId = rId;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(final Object obj) {
		boolean equals = false;
		if (obj instanceof SpriteImageObject
				&& ((SpriteImageObject) obj).textureId == textureId
				&& ((SpriteImageObject) obj).refId == refId) {
			equals = true;
		}
		return equals;
	}
	/**
	 * Gets the parentHeight. 
	 * @return {@link float}
	 */
	public float getParentHeight() {
		return parentHeight;
	}
	/**
	 * Gets the parentWidth. 
	 * @return {@link float}
	 */
	public float getParentWidth() {
		return parentWidth;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		return super.hashCode();
	}
	/**
	 * Gets the bottom coordinates.
	 * @return float
	 */
	public float getBottom() {
		return bottom;
	}
	/**
	 * Gets the image's height.
	 * @return int
	 */
	public int getHeight() {
		return height;
	}
	/**
	 * Gets the left coordinates.
	 * @return float
	 */
	public float getLeft() {
		return left;
	}
	/**
	 * Gets the image's reference id.
	 * @return int
	 */
	public int getRefId() {
		return refId;
	}
	/**
	 * Gets the right coordinates.
	 * @return float
	 */
	public float getRight() {
		return right;
	}
	/**
	 * Gets the image's texture id.
	 * @return int
	 */
	public int getTextureId() {
		return textureId;
	}
	/**
	 * Gets the top coordinates.
	 * @return float
	 */
	public float getTop() {
		return top;
	}
	/**
	 * Gets the image's width.
	 * @return int
	 */
	public int getWidth() {
		return width;
	}
}
